﻿namespace HySoft.Cash.Business
{
    using Huayou.Common.Database;
    using Huayou.Utils;
    using HySoft.Cash.BaseClass;
    using HySoft.Cash.DB;
    using HySoft.Cash.Structure;
    using System;
    using System.Data;
    using System.Web.UI;

    public class TsysruleBN : BaseBusiness
    {
        private TsysruleDB db;

        public TsysruleBN(Page page) : base(page)
        {
            this.db = null;
            this.db = new TsysruleDB(base.curDBOperater);
        }

        public TsysruleBN(Page page, DBOperate oper) : base(page, oper)
        {
            this.db = null;
            this.db = new TsysruleDB(base.curDBOperater);
        }

        public bool Add(TsysruleDT detail)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Add(detail);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return flag;
        }

        public bool Delete(int Sid)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Delete(Sid);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return flag;
        }

        public void Dispose()
        {
            base.Dispose();
            if (this.db != null)
            {
                this.db = null;
            }
        }

        public bool Edit(TsysruleDT detail)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Edit(detail);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return flag;
        }

        public TsysruleDT Get(int Sid)
        {
            TsysruleDT edt = null;
            try
            {
                try
                {
                    edt = this.db.Get(Sid);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return edt;
        }

        public DataTable GetList()
        {
            base.DBFieldList = "Sid,Name,Des";
            base.DBTable = "tSysRule";
            return base.CommonGetList();
        }

        public void QueryDes(string Des)
        {
            if ((Des != null) && (Des.Trim() != ""))
            {
                base.Filter = "Des like '%" + StringUtils.ToSQL(Des) + "%'";
            }
        }

        public void QueryName(string Name)
        {
            if ((Name != null) && (Name.Trim() != ""))
            {
                base.Filter = "Name like '%" + StringUtils.ToSQL(Name) + "%'";
            }
        }

        public void QuerySid(int Sid)
        {
            base.Filter = "Sid= " + Sid;
        }
    }
}

